<?php
namespace Modules\Buy\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Buy\Entities\Huowu;
use Modules\Buy\Http\Requests\HuowuRequest;
class HuowuController extends Controller
{
    //显示列表
    public function index()
    {
        $data = Huowu::paginate(10);
        return view('buy::huowu.index', compact('data'));
    }

    //创建视图
    public function create(Huowu $huowu)
    {
        return view('buy::huowu.create',compact('huowu'));
    }

    //保存数据
    public function store(HuowuRequest $request,Huowu $huowu)
    {
        $huowu->fill($request->all());
        $huowu->save();

        return redirect('/buy/huowu')->with('success', '保存成功');
    }

    //显示记录
    public function show(Huowu $field)
    {
        return view('buy::huowu.show', compact('field'));
    }

    //编辑视图
    public function edit(Huowu $huowu)
    {
        return view('buy::huowu.edit', compact('huowu'));
    }

    //更新数据
    public function update(HuowuRequest $request, Huowu $huowu)
    {
        $huowu->update($request->all());
        return redirect('/buy/huowu')->with('success','更新成功');
    }

    //删除模型
    public function destroy(Huowu $huowu)
    {
        $huowu->delete();
        return redirect('buy/huowu')->with('success','删除成功');
    }
}
